var _contactUtil = require("../../../utils/contact-util");

function _objectWithoutProperties(t, a) {
    if (null == t) return {};
    var o, e, i = _objectWithoutPropertiesLoose(t, a);
    if (Object.getOwnPropertySymbols) {
        var n = Object.getOwnPropertySymbols(t);
        for (e = 0; e < n.length; e++) o = n[e], 0 <= a.indexOf(o) || Object.prototype.propertyIsEnumerable.call(t, o) && (i[o] = t[o]);
    }
    return i;
}

function _objectWithoutPropertiesLoose(t, a) {
    if (null == t) return {};
    var o, e, i = {}, n = Object.keys(t);
    for (e = 0; e < n.length; e++) o = n[e], 0 <= a.indexOf(o) || (i[o] = t[o]);
    return i;
}

var _global = global, api = _global.api, json = _global.json, apiCode = _global.apiCode;

Page({
    data: {
        mobile: "186-8021-1000"
    },
    onLoad: function(t) {
        this.query = t, this.loadView();
    },
    loadView: function() {
        var c = this;
        api.minicard.contact.view({
            data: {
                guid: this.query.guid
            }
        }).then(function(t) {
            if (t.code === apiCode.SUCCESS) {
                var a = t.data, o = a.contact, e = a.total, i = a.ischarge, n = a.servertime, r = _objectWithoutProperties(a, [ "contact", "total", "ischarge", "servertime" ]);
                (0, _contactUtil.formatContact)(o, e, i, n), c.setData({
                    contact: o,
                    extraContact: r
                });
            }
        });
    },
    loadVersion: function() {
        var o = this;
        json.vip().then(function(t) {
            var a = t.buyYears;
            o.setData({
                discount: Math.min.apply(Math, a.map(function(t) {
                    return t.discount;
                }))
            });
        });
    },
    apply: function() {
        var a = this, t = this.data, o = t.contact.guid, e = t.extraContact, i = e.tryoutdaynum, n = e.tryoutstatus;
        api.minicard.contact.tryout({
            data: {
                guid: o
            }
        }).then(function(t) {
            (0, _contactUtil.loadContact)(), a.$put("contact.data", {
                guid: o,
                discount: a.query.discount,
                tryoutdaynum: i,
                tryoutstatus: n
            }), a.$route("/pages/radar/applysuccess/applysuccess");
        });
    },
    open: function() {
        (0, _contactUtil.gotoVersion)(this.data.contact.guid, "", !0);
    },
    call: function() {
        wx.makePhoneCall({
            phoneNumber: this.data.mobile
        });
    }
});